home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / prtcs155.zip / X.REX < prev    next >
OS/2 REXX Batch file  |  1994-01-14  |  2KB  |  86 lines

  1. /**/
  2. v="$VER: X  Rexx  Automatic archive detection and extraction          50.00"
  3. packer.     = ""        ; cmd.      = ""
  4. packer.arc  = "pkxarc"  ; cmd.arc   = "-e"
  5. packer.zoo  = "Zoo"     ; cmd.zoo   = "x.//"
  6. packer.lha  = "lha"     ; cmd.lha   = "-x0 -M e"
  7.  
  8. packer.zip  = "unzip"   ; cmd.zip   = "-xjn "
  9. packer.arj  = "unarj"   ; cmd.arj   = "e"
  10. packer.ape  = "ape"     ; cmd.ape   = "x"
  11.  
  12. trace background
  13. options failat 10
  14.  
  15. signal on halt
  16. signal on ioerr
  17. signal on break_c
  18.  
  19. log=show('P','ROOFLOG')
  20. sv="v"||right(v,5)
  21. script='X'
  22.  
  23. if arg() = 0 then exit 10
  24.  
  25. if GetClip('ASYNC') = 'TRUE' then do
  26. wspec = 'RAW:0/10/640/30/ROOF 'script sv'/INACTIVE/AUTO/SCREEN'||GetClip('ASYNCSCREEN')
  27. close('STDOUT');open('STDOUT',wspec,'w')
  28. end
  29. call close 'STDIN';call open 'STDIN','*','R'
  30. parse upper arg file files
  31. PutLog("Scanning "file "spec:"files,10,10)
  32. if ~open('in', file, 'R') then do
  33. PutLog("Can't open" file,10,10)
  34. call cleanup
  35. exit 20
  36. end
  37. buff = readch('in', 8)
  38. call close('in')
  39. select
  40. when left(buff,4) == 'ZOO ' then type = zoo
  41. when left(buff,4) == '$JGE' then type = ape
  42. when substr(buff,3,3) == '-lh' then type = lha
  43. when left(buff,2) == 'PK' then type = zip
  44. when left(buff,2) == '60'x||'EA'x then type = arj
  45. when left(buff,1) == '1A'x then type = arc
  46. otherwise do
  47. PutLog("Cannot handle" file,10,10)
  48. call cleanup
  49. exit 20
  50. end;end
  51.  
  52. if cmd.type=="" then do
  53. PutLog("Command unknown",10,10)
  54. call cleanup
  55. exit 20
  56. end
  57.  
  58. PutLog('Un'type'ing' files 'from' file,10,10)
  59. if GetClip('ASYNC') ~= 'TRUE' then address COMMAND packer.type cmd.type file files
  60. else address COMMAND packer.type '>NIL:' cmd.type file files
  61. arcode=RC
  62. call cleanup
  63. exit arcode
  64.  
  65. PutLog:  procedure expose log script
  66. if arg(3) < GetClip('STATUSLEVEL') then say arg(1)
  67. if arg(2) > GetClip('LOGLEVEL') then return 0
  68. if log then address 'ROOFLOG' 'logline' left(time(),5) script': 'arg(1)
  69. return 0
  70.  
  71. cleanup:
  72. if GetClip('ASYNC') = 'TRUE' then do
  73. aenum = GetCLip('ASYNCEVENT')
  74. if (aenum <= 1) then call SetCLip('ASYNCEVENT',"")
  75. else do
  76. aenum=aenum-1; call SetCLip('ASYNCEVENT',aenum)
  77. end;end
  78. return 0
  79.  
  80. /* Error Handling */
  81. halt:
  82. ioerr:
  83. break_c:
  84. call cleanup
  85. exit 10
  86.